<?php 
if (isset($_GET['fop'], $_GET['sop'], $_GET['type'])) {
	$fop = (float) $_GET['fop'];
	$sop = (float) $_GET['sop'];

	$result = array();

	switch ($_GET['type']) {
		case 'add':
			$result['result'] = $fop + $sop;
			echo json_encode($result); 
			break;
		case 'sup':
			$result['result'] = $fop - $sop;
			echo json_encode($result); 
			break;

		case 'div':
			$result['result'] = $fop / $sop;
			echo json_encode($result); 
			break;

		case 'mul':
			$result['result'] = $fop * $sop;
			echo json_encode($result); 
			break;

		default:
			$result['result'] = "Some error! Try again.";
			echo json_encode($result); 
			break;
	}
}


?>